<extend name="./Application/Common/View/block/base.php" />
<block name="header">
    <include file="./Application/Admin/View/block/easyui_header.php" />
    <link href="__PUBLIC__/css/Announce/index.css" rel="stylesheet" type="text/css" />
    <link href="__PUBLIC__/css/page.css" rel="stylesheet" type="text/css" />
</block>
<block name="bdoy">
    <body>
        <div class="top_nav">
            <div class="cont line-x">
                <a class="easyui-linkbutton add ref-btn" data-options="iconCls:'icon-add'" href="javascript:open_window('{:LANG('announce_add')}', '__URL__/add')">{:LANG('announce_add')}</a>
                <span class="gap-span">|</span>
                <a class="easyui-linkbutton">{:LANG('check_announce')}</a>
            </div>
        </div>
        <div class="table-cont">
            <form>
                <table width="100%" cellspacing="0">
                    <thead>
                        <tr>
                            <th width="35" align="center"><input type="checkbox" value="" id="check_box" onclick="check_all();"></th>
                            <th width="300" align="center">标题</th>
                            <th width="68" align="center">起始日期</th>
                            <th width="68" align="center">截止日期</th>
                            <th width="68" align="center">录入者</th>
                            <th width="50" align="center">审核状态</th>
                            <th width="120" align="center">发表时间</th>
                            <th width="69" align="center">管理操作</th>
                        </tr>
                    </thead>
                    <tbody>
                    <volist name="list" id="item">
                        <tr>
                            <td width="35"><input class="id_box" type="checkbox" name="ids[]" value="{$item['id']}"/></td>
                            <td width="300" align="center">{$item['title']}</td>
                            <td width="68">{$item['start_time']|substr=###,0,11}</td>
                            <td width="68">{$item['end_time']|substr=###,0,11}</td>
                            <td width="68">{$item['writer']}</td>
                            <td width="50">{:filter_status($item['status'])}</td>
                            <td width="120">{$item['createtime']|substr=###,0,11}</td>
                            <td width="69">
                                <a href="javascript:open_edit({$item['id']})" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-edit'" title="{:LANG('edit')}"></a>
                                <a href="javascript:del_item('{$item['id']},')" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-cancel'" title="{:LANG('del')}"></a>
                            </td>
                        </tr>
                    </volist>
                    </tbody>
                </table>
                <div class="btn">
                    <label for="check_box">全选/取消</label>
                    <input name="submit" type="submit" class="button" value="取消批准选定的公告" onclick="cancel_item()">&nbsp;&nbsp;
                    <input name="submit" type="submit" class="button" value="删除选定的公告" onclick="del_ids();">&nbsp;&nbsp;
                </div>
                <div class="pages">
                    {$page}
                </div>
            </form>
        </div>

        <div class="hide-div">
            <div id="window" class="easyui-window" title="{:LANG('announce')}" data-options="modal:true,closed:true" style="width:900px;height:500px;padding:0px;overflow: hidden;">
                <iframe id="window_iframe" style="width: 100%;height: 100%;padding: 0px;"></iframe>
            </div>
        </div>
    </body>
</block>
<block name="footExtendJs">
    <script>
        function open_window(title, url){
            $('#window').attr('title', title);
            $('#window').window('open');
            $('#window_iframe').attr('src', url);
        }

        function open_edit(id){
            var url = '__URL__/edit?id='+id;
            open_window('', url);
        }

        function check_all(){
            var temp;
            if($('#check_box').prop('checked')){
                temp = $('#check_box').prop('checked');
            }else{
                temp = $('#check_box').prop('checked');
            }
            $(".id_box").each(function(){
                $(this).prop('checked', temp);
            });
        }

        function get_ids(){
            var ids = '';
            $(".id_box").each(function(){
               if($(this).prop('checked')){
                   ids += ','+$(this).val();
               }
            });
            return ids;
        }

        function del_ids(){
            var ids = get_ids();
            del_item(ids);
        }

        function del_item(ids){
            var temp = confirm('您确定要删除吗？');
            if(temp == true){
                var url = '__URL__/del';
                var data = {'ids':ids};
                $.post(url, data, function(result){
                    window.location.href =  window.location.href;
                });
            }
        }

        function cancel_item(){
            var temp = confirm('您确定要删除吗？');
            if(temp == false){
                return;
            }
            var ids = get_ids();
            var url = '__URL__/cancel';
            var data = {'ids':ids};
            $.post(url, data, function(result){
                window.location.href =  window.location.href;
            });
        }
    </script>
</block>
